# coding:utf8
# 初始化文件
from flask import Flask, render_template
import pymysql
from flask_sqlalchemy import SQLAlchemy
from . import config
import os


app = Flask(__name__)

pymysql.install_as_MySQLdb()

app.config.from_object(config)
app.config["UP_DIR"] = os.path.join(os.path.abspath(os.path.dirname(__file__)), "static/uploads/")
app.debug = True

db = SQLAlchemy(app)

from app.home import home as home_blueprint
from app.admin import admin as admin_blueprint

app.register_blueprint(home_blueprint)
app.register_blueprint(admin_blueprint, url_prefix="/admin")


# 404
@app.errorhandler(404)
def page_not_found(error):
    return render_template('home/404.html'), 404
